# Copyright 2010-2024 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")

package(default_visibility = ["//visibility:public"])

config_setting(
    name = "on_linux",
    constraint_values = [
        "@platforms//os:linux",
    ],
)

config_setting(
    name = "on_macos",
    constraint_values = [
        "@platforms//os:macos",
    ],
)

config_setting(
    name = "on_windows",
    constraint_values = [
        "@platforms//os:windows",
    ],
)

cc_library(
    name = "adaptative_parameter_value",
    hdrs = ["adaptative_parameter_value.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "lazy_mutable_copy",
    hdrs = ["lazy_mutable_copy.h"],
    deps = ["@com_google_absl//absl/memory"],
)

cc_library(
    name = "affine_relation",
    hdrs = ["affine_relation.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:iterator_adaptors",
    ],
)

cc_library(
    name = "flat_matrix",
    hdrs = ["flat_matrix.h"],
    deps = [
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "random_engine",
    hdrs = ["random_engine.h"],
    deps = [],
)

cc_library(
    name = "bitset",
    srcs = ["bitset.cc"],
    hdrs = ["bitset.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "integer_pq",
    hdrs = [
        "integer_pq.h",
    ],
    deps = [
        "//ortools/base",
    ],
)

cc_library(
    name = "cached_log",
    srcs = ["cached_log.cc"],
    hdrs = ["cached_log.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:types",
    ],
)

cc_library(
    name = "zvector",
    hdrs = ["zvector.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "permutation",
    hdrs = ["permutation.h"],
    deps = ["//ortools/base"],
)

#cc_library(
#    name = "step_function",
#    srcs = ["step_function.cc"],
#    hdrs = ["step_function.h"],
#    deps = [
#        "@com_google_absl//absl/strings",
#        ":iterators",
#        "//ortools/base",
#    ],
#)

cc_library(
    name = "saturated_arithmetic",
    hdrs = ["saturated_arithmetic.h"],
    deps = [
        ":bitset",
        "//ortools/base",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "piecewise_linear_function",
    srcs = ["piecewise_linear_function.cc"],
    hdrs = ["piecewise_linear_function.h"],
    deps = [
        ":saturated_arithmetic",
        "//ortools/base",
        "//ortools/base:types",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_library(
    name = "rational_approximation",
    srcs = ["rational_approximation.cc"],
    hdrs = ["rational_approximation.h"],
    deps = [
        "//ortools/base",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sorted_interval_list",
    srcs = ["sorted_interval_list.cc"],
    hdrs = ["sorted_interval_list.h"],
    deps = [
        ":saturated_arithmetic",
        "//ortools/base",
        "@com_google_absl//absl/container:inlined_vector",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "string_array",
    hdrs = ["string_array.h"],
)

cc_library(
    name = "string_util",
    srcs = ["string_util.cc"],
    hdrs = ["string_util.h"],
    deps = [
        "//ortools/base",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_library(
    name = "tuple_set",
    hdrs = ["tuple_set.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:hash",
    ],
)

cc_library(
    name = "stats",
    srcs = ["stats.cc"],
    hdrs = ["stats.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:stl_util",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        #        "@com_google_absl//absl/strings:human_readable",
        "//ortools/port:sysinfo",
        "//ortools/base:timer",
        "//ortools/port:utf8",
    ],
)

cc_library(
    name = "time_limit",
    srcs = ["time_limit.cc"],
    hdrs = ["time_limit.h"],
    deps = [
        ":running_stat",
        "//ortools/base",
        "//ortools/base:sysinfo",
        "//ortools/base:timer",
        "//ortools/base:types",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "fp_utils",
    srcs = ["fp_utils.cc"],
    hdrs = ["fp_utils.h"],
    # -frounding-math is needed for code that uses IEEE-754 rounding modes.
    # You must also set this flag if you depend on this target and use
    # its methods related to IEEE-754 rounding modes.
    copts = select({
        "on_linux": ["-frounding-math"],
        "on_macos": ["-frounding-math"],
        "on_windows": [],
        "//conditions:default": ["-frounding-math"],
    }),
    deps = [
        ":bitset",
        "//ortools/base",
    ],
)

cc_library(
    name = "monoid_operation_tree",
    srcs = [],
    hdrs = ["monoid_operation_tree.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "return_macros",
    hdrs = ["return_macros.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "running_stat",
    hdrs = ["running_stat.h"],
    deps = ["//ortools/base"],
)

cc_library(
    name = "file_util",
    srcs = ["file_util.cc"],
    hdrs = ["file_util.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:dump_vars",
        "//ortools/base:file",
        "//ortools/base:gzipstring",
        "//ortools/base:hash",
        "//ortools/base:recordio",
        "//ortools/base:status_macros",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "proto_tools",
    srcs = ["proto_tools.cc"],
    hdrs = ["proto_tools.h"],
    deps = [
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "//ortools/base",
        "//ortools/base:file",
        "//ortools/base:hash",
        #        "//net/proto2/io/public",
        #        "//net/proto2/io/public:io",
        #        "//net/proto2/public",
        #        "//net/proto2/util/public:json",
        "@com_google_protobuf//:protobuf",
    ],
)

# Int128
proto_library(
    name = "int128_proto",
    srcs = ["int128.proto"],
)

cc_proto_library(
    name = "int128_cc_proto",
    deps = [":int128_proto"],
)

py_proto_library(
    name = "int128_py_pb2",
    deps = [":int128_proto"],
)

# OptionalBoolean
proto_library(
    name = "optional_boolean_proto",
    srcs = ["optional_boolean.proto"],
)

cc_proto_library(
    name = "optional_boolean_cc_proto",
    deps = [":optional_boolean_proto"],
)

py_proto_library(
    name = "optional_boolean_py_pb2",
    deps = [":optional_boolean_proto"],
)

# SWIG
cc_library(
    name = "functions_swig_helpers",
    hdrs = [
        "functions_swig_helpers.h",
    ],
    deps = ["//ortools/base"],
)

cc_library(
    name = "functions_swig_test_helpers",
    testonly = 1,
    hdrs = [
        "functions_swig_test_helpers.h",
    ],
    deps = ["//ortools/base"],
)

cc_library(
    name = "range_minimum_query",
    hdrs = ["range_minimum_query.h"],
    deps = [":bitset"],
)

cc_library(
    name = "range_query_function",
    srcs = ["range_query_function.cc"],
    hdrs = ["range_query_function.h"],
    deps = [
        ":range_minimum_query",
        "//ortools/base",
    ],
)

cc_library(
    name = "rev",
    hdrs = ["rev.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:map_util",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sigint",
    srcs = ["sigint.cc"],
    hdrs = ["sigint.h"],
    deps = [
        "//ortools/base",
    ],
)

cc_library(
    name = "vector_or_function",
    hdrs = ["vector_or_function.h"],
    deps = [
        "//ortools/base",
    ],
)

cc_library(
    name = "filelineiter",
    hdrs = ["filelineiter.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:file",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

#cc_library(
#    name = "bp_parser",
#    srcs = ["bp_parser.cc"],
#    hdrs = ["bp_parser.h"],
#    deps = [
#        "@com_google_absl//absl/strings",
#        ":filelineiter",
#        "//ortools/base",
#        "//ortools/base:file",
#    ],
#)

cc_library(
    name = "qap_reader",
    srcs = ["qap_reader.cc"],
    hdrs = ["qap_reader.h"],
    deps = [
        "//ortools/util:filelineiter",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sort",
    hdrs = ["sort.h"],
    deps = [
        "//ortools/base",
    ],
)

cc_library(
    name = "logging",
    srcs = ["logging.cc"],
    hdrs = ["logging.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:timer",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "testing_utils",
    hdrs = ["testing_utils.h"],
)

cc_library(
    name = "strong_integers",
    hdrs = ["strong_integers.h"],
    deps = [
        "//ortools/base",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "status_macros",
    hdrs = ["status_macros.h"],
    deps = [
        "//ortools/base:status_macros",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "fp_roundtrip_conv",
    srcs = ["fp_roundtrip_conv.cc"],
    hdrs = ["fp_roundtrip_conv.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:status_builder",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_library(
    name = "fp_roundtrip_conv_testing",
    testonly = 1,
    hdrs = ["fp_roundtrip_conv_testing.h"],
    deps = [
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "parse_proto",
    srcs = ["parse_proto.cc"],
    hdrs = ["parse_proto.h"],
    deps = [
        "@com_google_absl//absl/strings",
        "@com_google_protobuf//:protobuf",
    ],
)
